
package com.lee.utils;

public class LaplaceUtils {
 
    public static double laplaceNoisy(double sensitivity, double epsilon ){
        double r = Math.random() - 0.5;
        double Y = - (sensitivity/epsilon) * Math.signum(r) * Math.log(1.0-2*Math.abs(r));
        return Y;

    }
    public static long laplaceMeth(long data){
        data += laplaceNoisy(ConstantsUtils.SENSITIVITY,ConstantsUtils.EPSILON);
        return data;
    }



    public static void main(String[] args) {
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));
        System.out.println(laplaceMeth(10));

    }
} 
